﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Yatagan.IoC.ObjectBuilder
{
    internal class ObjectDirector
    {
        internal static object Create(Type type)
        {
            IoCElements.Component component = Current.Instance.IoCComponents[type];

            BaseObjectCreator objectCreator;
            switch (component.ObjectCreationType)
            {
                case ObjectCreationType.New:
                    objectCreator = new NewCreator();
                    break;
                case ObjectCreationType.Single:
                    objectCreator = new SingletonCreator();
                    break;
                case ObjectCreationType.Clone:
                    objectCreator = new CloneCreator();
                    break;
                default:
                    objectCreator = new NewCreator();
                    break;
            }

            return objectCreator.Create(component.TypeType);
        }
    }
}
